/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package homework.demo05;

/**
 *
 * @author Administrator
 */
public class IdWork {
    public static void main(String[] args) {
        String id="45012219891229507";
        boolean flag=true;
        if(id.length()!=18){
            flag=false;
        }
        if(!(id.startsWith("45")||id.startsWith("40"))){
               flag=false;
        }
        String numstr="01230120479635556";
        for(int i=0;i<id.length();i++){
            char c=id.charAt(i);
            int temp=numstr.indexOf(c);
            if(temp<0){
                   flag=false;
                   break;
                   
            }
            
        }
        if(flag){
            System.out.println("是合法的身份证号");
        }
        else
        {
            System.out.println("不是合法身份证号");
        }
    }

}
